package com.bp.scoringgun.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bp.scoringgun.entity.User;
import com.bp.scoringgun.mapper.UserMapper;
import com.bp.scoringgun.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    public void updateUserScoreAndRank(Long userId, double score, int rank) {
        User user = this.getById(userId);
        try {
            if (user != null) {
                user.setScore(score);
                user.setUserRank((long) rank);
                this.updateById(user);
            }
        }catch (Exception e){
//            e.printStackTrace();
            System.out.println("****");
            System.out.println(user);
            System.out.println(userId);
            System.out.println(score);
            System.out.println(rank);
            System.out.println("****");
        }

    }
}
